﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Web_Purchasehistory : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["current"] = "Sales";//current page
        if (Session["user"] != null)//check user
        {
            string user = Session["user"].ToString();
            if (user == "viewer")
            {
                Response.Redirect("index.aspx");
            }

        }
        else
        {
            Response.Redirect("index.aspx");
        }
    }

    protected void ASPxGridView1_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDataEventArgs e)//calculate total
    {
        try
        {
            if (e.Column.FieldName == "total")
            {
                decimal price = Convert.ToDecimal(e.GetListSourceFieldValue("Price"));
                int qty = Convert.ToInt32(e.GetListSourceFieldValue("Qty"));
                decimal tot = price * qty;
                e.Value = tot;
            }
        }
        catch
        {
            Response.Redirect("404.aspx");
        }
    }
}